//
//  SKMainViewController.m
//  WeiBo(MVVM-OC)
//
//  Created by yanli on 16/7/15.
//  Copyright © 2016年 mountainPassCell. All rights reserved.
//

#import "SKMainViewController.h"

@interface SKMainViewController ()

@end

@implementation SKMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //  创建制定的 撰写 tabBar
    SKTabBar *skTabBar = [SKTabBar new];
    
    //   使用kvc给只读属性设置值
    [self setValue:skTabBar forKey:@"tabBar"];
    
    //  添加子视图
    [self addChildViewController:[SKHomeTableViewController new] title:@"首页" imageName:@"tabbar_home"];
    [self addChildViewController:[SKMessageTableViewController new] title:@"消息" imageName:@"tabbar_message_center"];
    [self addChildViewController:[SKDiscoverTableViewController new] title:@"发现" imageName:@"tabbar_discover"];
    [self addChildViewController:[SKProfileTableViewController new] title:@"我的" imageName:@"tabbar_profile"];
}



- (void)addChildViewController:(UIViewController *)childController title:(NSString *)title imageName:(NSString *)imageName {
    //  设置子控制器 标题
    childController.title = title;
    //  设置子控制器 图片
    childController.tabBarItem.image = [UIImage imageNamed:imageName];
    //  指定渲染模式
    NSString *selectedImageStr = [NSString stringWithFormat:@"%@_selected",imageName];
    UIImage *selectedImage1 = [UIImage imageNamed:selectedImageStr];
    UIImage *selectedImage2 = [selectedImage1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childController.tabBarItem.selectedImage = selectedImage2;
    //  设置tabbar 字体颜色
    [childController.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor orangeColor]} forState:UIControlStateSelected];
    //  设置字体
    [childController.tabBarItem setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14]} forState:UIControlStateNormal];
    //  添加子视图控制器
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:childController];
    
    [self addChildViewController:nav];
}







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
















